package cn.hairui.blog.repository;

import cn.hairui.blog.mapper.ArticalMapper;
import cn.hairui.blog.model.Artical;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @author lihairui
 * @version V1.0
 * @date: 2019/3/9 2:54
 */
@Repository
public class ArticalRepository {

    @Autowired
    private ArticalMapper articalMapper;

    public List<Artical> queryByNavid(Integer navid, int count) {
        return articalMapper.queryByNavid(navid, count);
    }

    public List<Artical> findByCategoryIdLimited(Integer categoryId, int count) {
        return articalMapper.findByCategoryIdLimited(categoryId, count);
    }

    public List<Artical> findHotLimited(int count) {
        return articalMapper.findHotLimited(count);
    }

    public List<Artical> findTop() {
        return articalMapper.findTop();
    }

    public List<Artical> list() {
        return articalMapper.list();
    }

    public List<String> findAllTags(int count) {
        List<String> result = articalMapper.findAllTags();
        return result;
    }

    public int findCountBytag(String tagName) {
        return articalMapper.findCountBytag(tagName);
    }

    public List<Artical> findByCategoryId(Integer categoryId) {
        return articalMapper.findByCategoryId(categoryId);
    }

    public List<Map> listArchive() {
        return articalMapper.listArchive();
    }

    public List<Artical> findByCreateDateYm(String dateStr) {
        return articalMapper.findByCreateDateYm(dateStr);
    }

    public Artical find(int pk) {
        return articalMapper.find(pk);
    }

    public List<Artical> findByKeyword(String keyword) {
        return articalMapper.findByKeyword(keyword);
    }

    public List<Map> listMgr() {
        return articalMapper.listMgr();
    }

    public int countMgr() {
        return articalMapper.countMgr();
    }

    public void updateIntopSts(int id, String flag) {
        articalMapper.updateIntopSts(id, flag);
    }

    public int add(Artical artical) {
        articalMapper.insert(artical);
        return artical.getId();
    }

    public int delete(int pk) {
        Artical artical = new Artical();
        artical.setId(pk);
        return articalMapper.delete(artical);
    }

    public int update(Artical artical) {
        return articalMapper.update(artical);
    }

    public void updateContent(Artical artical) {
        articalMapper.updateContent(artical);
    }

    public List<String> findtags() {
        return articalMapper.findAllTags();
    }

    public List<Artical> findByTags(String tag) {
        return articalMapper.findByTags(tag);
    }

    public Artical findLast(int id) {
        return articalMapper.findLast(id);
    }

    public Artical findNext(int id) {
        return articalMapper.findNext(id);
    }

    public List<Artical> findByTopicId(Integer topicId) {
        return articalMapper.findByTopicId(topicId);
    }
}
